local hx__zhabing = fk.CreateSkill {
  name = "hx__zhabing",
  tags = {Skill.Compulsory},
}

hx__zhabing:addEffect(fk.TurnEnd, {
  anim_type = "control",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(hx__zhabing.name) then
      return #player.room.logic:getActualDamageEvents(1, function (e)
        return e.data.from == player
      end, Player.HistoryRound) == 0
    end
    return false
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.room:askToSkillInvoke(player, {skill_name = hx__zhabing.name, prompt = "诈病：回复一点体力，或点取消你获得效果：每轮开始时令你造成的伤害+1直到你造成伤害"}) then
      room:recover({
        who = player,
        num = 1,
        skillName = hx__zhabing.name
      })
    else
      room:addPlayerMark(player, "@@hx__zhabing_candamage")
    end
  end,
})

hx__zhabing:addEffect("maxcards", {
  correct_func = function(self, player)
    if player:hasSkill(hx__zhabing.name) then
      return 3
    end
    return 0
  end,
})

hx__zhabing:addEffect(fk.DamageCaused, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__zhabing.name) and player:getMark("@@hx__zhabing_candamage") ~= 0
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local x = player:getMark("@hx__zhabing_damage")
    data:changeDamage(x)
    room:setPlayerMark(player, "@hx__zhabing_damage", 0)
    room:setPlayerMark(player, "@@hx__zhabing_candamage", 0)
  end,
})

hx__zhabing:addEffect(fk.RoundStart, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(hx__zhabing.name) and player:getMark("@@hx__zhabing_candamage") ~= 0
  end,
  on_use = function(self, event, target, player, data)
    player.room:addPlayerMark(player, "@hx__zhabing_damage", 1)
  end,
})


return hx__zhabing